package com.nuo.backend.modules.common.local;

import com.nuo.backend.common.utils.FileUtils;
import com.nuo.backend.common.utils.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @description: TODO 文件上传
 * @author nuo
 * @date 2023/1/12 16:38
 * @version 1.0
 */
@RestController
@RequestMapping("storage/local")
public class local {

    @Autowired
    FileUtils fileUtils;

    // TODO 需部署至服务器才能生效
    @ApiOperation(value = "上传云服务器指定文件夹", consumes = "multipart/form-data")
    @PostMapping("/upload")
    public R uploadToTomcat(@RequestParam(value = "file") MultipartFile[] fileArr, @RequestParam String pathName) {
        return fileUtils.uploadToLocal(fileArr,pathName);
    }

}
